<template>
	<view>
		<view class="search" id="search">
			<view style="" class="search_container">
				<view class="top" style="padding-top: 5px;margin-bottom: 20rpx;">
					<u--input v-model="formData.value" @change="inputChange()"
						customStyle="background-color:#f2f2f2" shape="circle" placeholder="搜索订单(根据型号搜索)"
						suffixIcon="search" suffixIconStyle="color: #909399">
					</u--input>
				</view>
			</view>
			<view style="padding-top: 120rpx;z-index: 1;">
				<view class="order" v-for="(item,index) in orderList" :key="index">
					<view class="goods" style="position: relative;">
						<view class="left">
							<image style="width: 234rpx;height: 234rpx;"
								:src="item.img ? item.img : 'http://applet.atptest.com/2023081702.jpg'"
								mode="aspectFill"></image>
							<!-- <image style="width: 234rpx;height: 234rpx;" :src="item.img ? item.img : 'http://applet.atptest.com/MfaGs82a1694758004968.jpg?v=1694758009918'" mode="aspectFill"></image> -->
						</view>
						<view class="right">
							<view class="item" style="align-items: center;">
								<view>检测单号：</view>
								<view class="content_item">
									<view>{{item.orderNo}}</view>
									<image v-if="item.isMonthly"
										style="height: 26rpx;position: absolute;right: -10rpx;top: 0;"
										src="../../../static/img/mine/monthly.png" mode="heightFix"></image>
								</view>
							</view>
							<view class="item">
								<view>检测型号：</view>
								<view class="content_item">{{item.model}}</view>
							</view>
							<view class="item">
								<view>检测项目：</view>
								<view class="content_item">{{item.checkPorject}}</view>
							</view>
							<view class="item" v-if="item.state == 1">
								<view>检测日期：</view>
								<view class="content_item">{{item.checkTime}}</view>
							</view>
							<view class="item" v-else>
								<view>申请日期：</view>
								<view class="content_item">{{item.createTime}}</view>
							</view>
							<view class="logistics_price">
								<view class="logistics">
									{{item.checkStateValue}}
								</view>
								<view>
									订单金额：￥{{item.total}}
								</view>
							</view>
						</view>
					</view>
					<view class="btn">
						<view class="more">
							{{item.createTime}}
						</view>
						<view v-if="item.conclusionState == 1">
							<button style="color:#fff;background-color: #3b53b7;margin-left:10rpx;" size="mini"
								@click.stop="orderClick(item)">检测结论</button>
						</view>
						<view v-if="item.conclusionState == 1">
							<button style="color:#fff;background-color: #3b53b7;margin-left:10rpx;" size="mini"
								@click.stop="imgClick(item)">查看图片</button>
						</view>
					</view>
				</view>
				<view v-if="orderList.length < 1" class="noOrder" style="font-size: 36rpx;">
					<u-divider text="还没有相关订单"></u-divider>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		getCompanyOrderList
	} from "../../../api/order.js"
	export default {
		data() {
			return {
				inputValue: '',
				formData: {
					model: "",
					pageIndex: 1,
					pageSize: 8,
					userid: null,
				},
				orderNo: '',
				orderList: [],
			};
		},
		onLoad(option) {
			this.formData.userid = Number(option.headUserId)
			this.formData.pageIndex = 1
			this.orderList = []
			this.getList()
		},
		onReachBottom() {
			this.formData.pageIndex++
			this.getList()
		},
		methods: {

			// input搜索
			inputChange() {
				this.formData.pageIndex = 1
				this.orderList = []
				this.getList()
			},

			// 去检测结论页面
			orderClick(i) {
				uni.navigateTo({
					url: `/pagesB/pages/orderDetail/orderDetail?i=` + i.orderNo
				})
			},

			// 获取订单
			async getList() {
				uni.showLoading({
					title: '加载中',
				});
				const res = await getCompanyOrderList(this.formData)
				if (res) {
					this.orderList = this.orderList.concat(res)
					this.orderList.forEach(item => {
						if(item.checkState == null){
							item.checkStateValue = "检测中"
						}else if(item.checkState == 0){
							item.checkStateValue = "未通过"
						}else if(item.checkState == 1){
							item.checkStateValue = "已通过"
						}else{
							item.checkStateValue = "进一步分析"
						}
					})
					setTimeout(() => {
						uni.hideLoading();
					}, 200)
				} else {
					uni.hideLoading();
				}
			},

			// 查看图片
			imgClick(item) {
				uni.navigateTo({
					url: `/pagesB/pages/userChat/userChat?i=${item.orderNo}`
				})
			},

			//回到我的页面
			back() {
				uni.switchTab({
					url: "/pages/mine/mine"
				})
			}
		},

	}
</script>

<style lang="scss" scoped>
	scroll-view ::-webkit-scrollbar {
		display: none;
		width: 0;
		height: 0;
		color: transparent;
	}

	.send_container {
		width: 100%;
		display: flex;
		flex-direction: column;
	}

	.form_item {
		height: 74rpx;
		line-height: 74rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;

		.label {
			width: 80%;
			color: rgb(61, 61, 61);
			font-family: 思源黑体;
			font-size: 28rpx;
			font-weight: 400;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}

		.item_input {
			width: 80%;
		}

		.item_down {
			color: #2979ff;
			font-size: 24rpx
		}
	}

	.navBarBox {
		width: 100%;
		padding-left: 20rpx;
		z-index: 999 !important;
		position: fixed;
		left: 0;
		font-size: 28rpx;
		background-color: #fff;

		.navBar {
			width: 57%;
			display: flex;
			justify-content: space-between;
			position: relative;

			.nav_item {
				position: absolute;
				bottom: 15rpx;
			}
		}
	}

	.search {
		padding-bottom: 10rpx;

		.search_container {
			position: fixed;
			left: 0;
			top: 0;
			width: 100%;
			z-index: 999;
			box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.3);
			background-color: #fff;
		}

		.top {
			padding: 0 40rpx;
			background-color: #fff;
		}

		.order {
			margin: 10px 10px 0;
			padding: 20rpx;
			border-radius: 8rpx;
			background-color: #fff;
			box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.3);

			.goods {
				display: flex;
				justify-content: space-between;
				align-items: center;
				position: relative;
				border-bottom: 2px solid rgb(140, 140, 140);
				font-size: 28rpx;

				.left {
					width: 35%;
					padding-right: 10rpx;
				}

				.right {
					flex: 1;

					view {
						margin: 4rpx 0;
					}

					.item {
						display: flex;

						.content_item {
							width: 65%;
							display: flex;
							flex-wrap: wrap;
						}
					}
				}
			}

			.logistics_price {
				width: 100%;
				color: rgb(179, 0, 0);
				font-family: 思源黑体;
				font-size: 20rpx;
				font-weight: 500;
				display: flex;
				justify-content: space-between;

				.logistics {}
			}

			.totalPrice {
				font-size: 28rpx;
				text-align: right;
			}

			.btn {
				display: flex;
				align-items: center;
				justify-content: flex-end;
				padding-top: 20rpx;
				position: relative;

				.more {
					position: absolute;
					left: 0;
					color: rgb(104, 103, 103);
					font-family: 思源黑体;
					font-size: 18rpx;
					font-weight: 500;
				}
			}
		}

		.noOrder {
			display: flex;
			justify-content: center;
			margin-top: 200rpx;
			color: #7d7e7f;
		}
	}

	.nagetive {
		border-bottom: 3px solid #3b53b7;
		color: #000;
	}
</style>